﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using QLLUONG.BLL;
using QLLUONG.DTO;
namespace QLLUONG
{
    public partial class FormSearch : Form
    {
        public FormSearch()
        {
            InitializeComponent();
        }
        LuongBLL LBLL = new LuongBLL();
        ChucVuBLL CVBLL = new ChucVuBLL();
        NhanVienBLL NVBLL = new NhanVienBLL();
        private void FormSearch_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'qLLUONGDataSet1.LUONG' table. You can move, or remove it, as needed.
            this.lUONGTableAdapter.Fill(this.qLLUONGDataSet1.LUONG);
            // TODO: This line of code loads data into the 'qLLUONGDataSet.LUONG' table. You can move, or remove it, as needed.
            
            SelectRadio();
            FillCBBNghach();
        }
        public void FillCBBNghach()
        {
            cbbChucVu.DisplayMember = "TENCV";

            cbbChucVu.ValueMember = "MSCV";
            cbbChucVu.DataSource = CVBLL.Show();
        }
        public void SelectRadio()
        {
            if (RadioLuong.Checked == true)
            {
                
                cbbChucVu.Enabled = false;
                txtLuong.Enabled = true;
            }
            if(RadioNghach.Checked == true)
            {
                
                cbbChucVu.Enabled = true;
                txtLuong.Enabled = false;
            }
        }
        

        private void Searhbtn_Click(object sender, EventArgs e)
        {
            if (RadioLuong.Checked == true)
            {
                double Luong = double.Parse(txtLuong.Text);
                if (LBLL.SearchLuong(Luong).Count == 0)
                {
                    MessageBox.Show("Không Tìm Thấy Dữ Liệu");
                }
                else
                {
                    DataGridSearch.DataSource = LBLL.SearchLuong(Luong);
                }
                
            }
            if (RadioNghach.Checked == true)
            {
                String Nghach = cbbChucVu.Text;
                if (LBLL.SearchLuong(Nghach).Count == 0)
                {
                    MessageBox.Show("Không Tìm Thấy Dữ Liệu");
                }
                else
                {
                    DataGridSearch.DataSource = LBLL.SearchLuong(Nghach);
                }
                
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataGridSearch.DataSource = LBLL.Show();
            FormSearch_Load(sender, e);
        }

        private void DataGridSearch_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void Reload_Click(object sender, EventArgs e)
        {
            DataGridNhanVien.DataSource = NVBLL.Search(txtKey.Text);
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }
    }
}
